package com.kyzh.core.dialog

import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.app.AlertDialog
import com.kyzh.core.R
import com.kyzh.core.databinding.DialogSignRuleBinding


private var signRuleDialog:AlertDialog?=null

fun Activity.showSignRuleDialog(content:String,listener:()->Unit){
    signRuleDialog = AlertDialog.Builder(this, R.style.kyzhGuestLoginDialog)
            .setView(getView(content,listener))
            .create()

    signRuleDialog?.show()
}
private fun Activity.getView(content:String,listener:()->Unit):View{
    val binding = DialogSignRuleBinding.bind(LayoutInflater.from(this).inflate(R.layout.dialog_sign_rule,null,false))
    binding.apply {
        tvSign.setOnClickListener {
            listener()
            signRuleDialog?.dismiss()
        }
        tv2.text = content
    }
    return binding.root
}